<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/public/header.jsp"%>
<html>
	<head>
		<title>未付款清单</title>
	</head>
	<script type="text/javascript">
		$(function(){
			$("#dept_id").combotree({
				url:'<%=contextPath %>/springMVC/group/listDepartment',
				method:'POST',
				animate:true,
				lines:true,
				onChange:function(){
					doSearch();
				}
			});
			$("#gd_search").keypress(function(e) { 
		    	// 回车键事件 
		     	if(e.which == 13) { 
		     		 doSearch();
		       	} 
		   	}); 
			$("#xm_search").keypress(function(e) { 
		    	// 回车键事件 
		     	if(e.which == 13) { 
		     		 doSearch();
		       	} 
		   	}); 
			$("#supplier").keypress(function(e) { 
		    	// 回车键事件 
		     	if(e.which == 13) { 
		     		 doSearch();
		       	} 
		   	}); 
			$('#table').datagrid({
				title:'往来流水',
				rownumber:true,
				url:'<%=contextPath %>/springMVC/crm/listPageUnPurchaseSupplier', 
				loadMsg:'正在加载数据，请稍后......',
				fitColumns:true,
				nowrap:false,
				showFooter:true,
				columns:[[
					{title:'产生时间',field:'operation_date',width:200,align:'center'},
					{title:'部门',field:'dept_name',width:200,align:'center'},
					{title:'项目编号',field:'xm_code',width:200,align:'center'},
					{title:'项目名称',field:'xm_name',width:200,align:'center'},
					{title:'工单编号',field:'gd_code',width:200,align:'center'},
					{title:'工单名称',field:'gd_name',width:200,align:'center'},
					{title:'厂家名称',field:'supplier',width:200,align:'center'},
					{title:'未付金额',field:'money',width:200,align:'center'}
				]],
				pageSize:10,
				pageList : [10,50,100],  
				pagination:true,
				onLoadSuccess:function(rtJson){
					if(rtJson.rtState== '1')
					{
						warningInfo(rtJson.rtMsrg);
						return;
					}
					showFooter();
				}
			});
			//----end
		});
		function doSearch(){
			var xm_search = $('#xm_search').val();
			var gd_search = $('#gd_search').val();
			var supplier = $('#supplier').val();
			var dept_id = $("#dept_id").combotree('getValue');
			var start_date = $('#start_date').datebox('getValue');
			var end_date = $('#end_date').datebox('getValue');
			$('#table').datagrid('load',{
				start_date:start_date,
				end_date:end_date,
				xm_search:xm_search,
				gd_search:gd_search,
				supplier:supplier,
				dept_id:dept_id
			});
		}
		
		function showFooter(){
			var xm_search = $('#xm_search').val();
			var gd_search = $('#gd_search').val();
			var supplier = $('#supplier').val();
			var dept_id = $("#dept_id").combotree('getValue');
			var start_date = $('#start_date').datebox('getValue');
			var end_date = $('#end_date').datebox('getValue');
			var param="xm_search="+xm_search+"&gd_search="+gd_search+"&supplier="+supplier+"&dept_id="+dept_id+"&start_date="+start_date+"&end_date="+end_date;
			$.ajax({
				type:'POST',
				url:'<%=contextPath %>/springMVC/crm/getSumUnPurchaseSupplier',
				data:param,
				async:false,
				success:function(data){
					$('#table').datagrid('reloadFooter',[
                     	{supplier:'合计:',
                     	 money:data
                     	 }
                     ]);
				}
			});
		}
		function exportExcel()
		{
			var xm_search = $('#xm_search').val();
			var gd_search = $('#gd_search').val();
			var supplier = $('#supplier').val();
			var dept_id = $("#dept_id").combotree('getValue');
			var start_date = $('#start_date').datebox('getValue');
			var end_date = $('#end_date').datebox('getValue');
			var param="xm_search="+xm_search+"&gd_search="+gd_search+"&supplier="+supplier+"&dept_id="+dept_id+"&start_date="+start_date+"&end_date="+end_date;
			
			window.open('<%=contextPath%>/springMVC/excel/unPurchaseSupplierExcel?'+param);
		}
	</script>
	<body style="height: 97%">
		    	    <div id="table"  data-options="fit:true,toolbar:'#queryParamDiv'"></div>  
		    	    <div id="queryParamDiv" style="padding:3px;height:auto">
						<div align="right">
							部门：<input  id="dept_id" name="dept_id" class="easyui-combotree">&nbsp;&nbsp;
							项目：<input id="xm_search" name="xm_search" style="width:110px" title="项目编号/名称" placeholder="项目编号/名称 "/>&nbsp;&nbsp;
							工单：<input id="gd_search" name="gd_search" style="width:110px" title="工单编号/名称" placeholder="工单编号/名称 "/>&nbsp;&nbsp;
							厂家：<input id="supplier" name="supplier" style="width:110px" title="厂家" placeholder="厂家 "/>&nbsp;&nbsp;
							开始日期: <input id="start_date" name="start_date" class="easyui-datebox" />
							结束日期: <input id="end_date" name="end_date" class="easyui-datebox" />&nbsp;&nbsp;
							<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="doSearch();">搜索</a>
							<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-excel',plain:true" onclick="exportExcel();"></a>
						</div>
					</div>
	</body>
</html>
